home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10793 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: in2.uu.net!interaccess!pbrianmcg
  2. From: brianmcg@interaccess.com (Brian V. McGroarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Writing A Pointer To Memory
  5. Date: 20 Mar 1996 03:07:52 GMT
  6. Organization: InterAccess, Chicago's best Internet Service Provider
  7. Message-ID: <4insq8$99t@nntp.interaccess.com>
  8. NNTP-Posting-Host: d54-isdn.nhe.interaccess.com
  9. X-Newsreader: News Xpress Version 1.0 Beta #4
  10.  
  11. MS-DOS 16-bit mode "far" pointers aren't entirely safe for pointer 
  12. arithmetic.  In some modes, MS-DOS compilers will wrap through a 64k segment 
  13. when performing pointer arithmetic.  You will need a "huge" pointer, which 
  14. can be used for pointer arithmetic through the entire range of low memory.
  15.  
  16.  
  17. Try: 
  18.  
  19. void far *ptr = far pointer to a structure;
  20.  
  21. void huge *desiredDestinationPtr;
  22. desiredDestinationPtr = ((void huge *)locationPtr) - sizeof(void far *);
  23.  
  24. Note that more pedantic compiler modes will require that you recast the void 
  25. pointer to another data type pointer before you can perform arithmetic on it, 
  26. claiming that "void" has no size.
  27.  
  28.  
  29. Nathan T. Wild wrote:
  30.  
  31. [...]
  32.  
  33. > the location in RAM that I have to write to is 
  34. > 2xsizeof(far *) or 8 bytes back from a specific
  35. > location in memory.
  36.  
  37. > I know where I need to write the pointer, and what I
  38. > need to write, but for some strange reason I cannot get
  39. > it to do what I want...
  40.  
  41. >take:
  42.  
  43. >void far *ptr = far pointer to a structure;
  44.  
  45. > desiredDestinationPtr = (locationPtr - sizeof(void far *));
  46.  
  47. [...]
  48.  
  49. > Please respond via email asap...
  50.  
  51. Copied.
  52.  
  53.  
  54.  
  55. ---
  56. Brian Valters McGroarty -- brianmcg@bix.com
  57. phone/fax (847) 439-7714
  58.  
  59.  
  60.  
  61.  
  62.  
  63.